﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using LFloatMath.Math;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(SkillEditorConst.SkillEffective + "/" + SkillEditorConst.Totem, typeof(SkillEditorGraph))]
    public class SkillEffectiveNode_Totem : SkillEffectiveNode
    {
        [InspectorName("是否跟随召唤者消失")] public bool deadWithSummoner;
        [InspectorName("范围")] public float range;
        [InspectorName("生效时机")] public SkillEffective_Totem_ConfigData.EActiveType eActiveType;
        [InspectorName("生效目标")]public ETargetRelation targetRelation;
        [InspectorName("图腾特效")]public string effectName;
        [InspectorName("持续时间")] public int duration;
        [Output("效果节点", false)] public SkillEditorActionNode actions;

        protected override ESkillEffectiveType effectType => ESkillEffectiveType.Totem;

        protected override void Process()
        {
            base.Process();
            this.actions = new SkillEditorActionNode()
            {
                setter = (x) => { (this.selfConfig.customConfig as SkillEffective_Totem_ConfigData)?.actions.Add(x); }
            };
        }

        protected override SkillCustomConfig CreateConfig()
        {
            var rConfig = new SkillEffective_Totem_ConfigData()
            {
                deadWithSummoner = this.deadWithSummoner,
                range = this.range.ToLFloat()._val,
                activeType = this.eActiveType,
                targetRelation = this.targetRelation,
                effectName = this.effectName,
                duration = this.duration,
                actions = new()
            };
            return rConfig;
        }
    }
}